<!-- https://gitlab.com/gitlab-org/gitlab-runner/blob/0362425dc5026417338ac6a823c53fe65b10c4a7/executors/shell/executor_shell.go -->
<div class="blob-content-holder" id="blob-content-holder">
<article class="file-holder">
<div class="js-file-title file-title-flex-parent">
<div class="file-header-content">
<i aria-hidden="true" data-hidden="true" class="fa fa-file-text-o fa-fw"></i>
<strong class="file-title-name qa-file-title-name">
executor_shell.go
</strong>
<button class="btn btn-clipboard btn-transparent prepend-left-5" data-toggle="tooltip" data-placement="bottom" data-container="body" data-class="btn-clipboard btn-transparent prepend-left-5" data-title="Copy file path to clipboard" data-clipboard-text="{&quot;text&quot;:&quot;executors/shell/executor_shell.go&quot;,&quot;gfm&quot;:&quot;`executors/shell/executor_shell.go`&quot;}" type="button" title="" aria-label="Copy file path to clipboard" data-original-title="Copy file path to clipboard"><svg><use xlink:href="https://gitlab.com/assets/icons-09fdf2c02921bad2ec7257465016a755f359ab7b598e5fe42c22381fe1a25045.svg#duplicate"></use></svg></button>
<small>
3.49 KB
</small>
</div>

<div class="file-actions">

<div class="btn-group" role="group"><button class="btn btn-sm js-copy-blob-source-btn" data-toggle="tooltip" data-placement="bottom" data-container="body" data-class="btn btn-sm js-copy-blob-source-btn" data-title="Copy source to clipboard" data-clipboard-target=".blob-content[data-blob-id='ee69145485df1f9d6af54041889079c6db435b09']" type="button" title="" aria-label="Copy source to clipboard" data-original-title="Copy source to clipboard"><svg><use xlink:href="https://gitlab.com/assets/icons-09fdf2c02921bad2ec7257465016a755f359ab7b598e5fe42c22381fe1a25045.svg#duplicate"></use></svg></button><a class="btn btn-sm has-tooltip" target="_blank" rel="noopener noreferrer" title="Open raw" data-container="body" href="/gitlab-org/gitlab-runner/raw/0362425dc5026417338ac6a823c53fe65b10c4a7/executors/shell/executor_shell.go"><i aria-hidden="true" data-hidden="true" class="fa fa-file-code-o"></i></a><a download="executors/shell/executor_shell.go" class="btn btn-sm has-tooltip" target="_blank" rel="noopener noreferrer" title="Download" data-container="body" href="/gitlab-org/gitlab-runner/raw/0362425dc5026417338ac6a823c53fe65b10c4a7/executors/shell/executor_shell.go?inline=false"><svg><use xlink:href="https://gitlab.com/assets/icons-09fdf2c02921bad2ec7257465016a755f359ab7b598e5fe42c22381fe1a25045.svg#download"></use></svg></a></div>
<div class="btn-group" role="group"><span class="btn btn-sm path-lock disabled has-tooltip" data-toggle="tooltip" title="You do not have permission to lock this">Lock</span>
<button name="button" type="submit" class="btn js-edit-blob  disabled has-tooltip" title="You can only edit files when you are on a branch" data-container="body">Edit</button><button name="button" type="submit" class="btn btn-default disabled has-tooltip" title="You can only edit files when you are on a branch" data-container="body">Web IDE</button><button name="button" type="submit" class="btn btn-default disabled has-tooltip" title="You can only replace files when you are on a branch" data-container="body">Replace</button><button name="button" type="submit" class="btn btn-remove disabled has-tooltip" title="You can only delete files when you are on a branch" data-container="body">Delete</button></div>
</div>
</div>
<div class="js-file-fork-suggestion-section file-fork-suggestion hidden">
<span class="file-fork-suggestion-note">
You're not allowed to
<span class="js-file-fork-suggestion-section-action">
edit
</span>
files in this project directly. Please fork this project,
make your changes there, and submit a merge request.
</span>
<a class="js-fork-suggestion-button btn btn-grouped btn-inverted btn-success" rel="nofollow" data-method="post" href="/gitlab-org/gitlab-runner/blob/0362425dc5026417338ac6a823c53fe65b10c4a7/executors/shell/executor_shell.go">Fork</a>
<button class="js-cancel-fork-suggestion-button btn btn-grouped" type="button">
Cancel
</button>
</div>

<script id="js-file-lock" type="application/json">
{"path":"executors/shell/executor_shell.go","toggle_path":"/gitlab-org/gitlab-runner/path_locks/toggle"}
</script>


<div class="blob-viewer" data-type="simple" data-url="/gitlab-org/gitlab-runner/blob/0362425dc5026417338ac6a823c53fe65b10c4a7/executors/shell/executor_shell.go?format=json&amp;viewer=simple" data-loading="true" data-loaded="true"><div class="blob-viewer" data-type="simple">
<div class="file-content code js-syntax-highlight qa-file-content white">
<div class="line-numbers">
<a class="diff-line-num" data-line-number="1" href="#L1" id="L1">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
1
</a>
<a class="diff-line-num" data-line-number="2" href="#L2" id="L2">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
2
</a>
<a class="diff-line-num" data-line-number="3" href="#L3" id="L3">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
3
</a>
<a class="diff-line-num" data-line-number="4" href="#L4" id="L4">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
4
</a>
<a class="diff-line-num" data-line-number="5" href="#L5" id="L5">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
5
</a>
<a class="diff-line-num" data-line-number="6" href="#L6" id="L6">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
6
</a>
<a class="diff-line-num" data-line-number="7" href="#L7" id="L7">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
7
</a>
<a class="diff-line-num" data-line-number="8" href="#L8" id="L8">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
8
</a>
<a class="diff-line-num" data-line-number="9" href="#L9" id="L9">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
9
</a>
<a class="diff-line-num" data-line-number="10" href="#L10" id="L10">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
10
</a>
<a class="diff-line-num" data-line-number="11" href="#L11" id="L11">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
11
</a>
<a class="diff-line-num" data-line-number="12" href="#L12" id="L12">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
12
</a>
<a class="diff-line-num" data-line-number="13" href="#L13" id="L13">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
13
</a>
<a class="diff-line-num" data-line-number="14" href="#L14" id="L14">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
14
</a>
<a class="diff-line-num" data-line-number="15" href="#L15" id="L15">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
15
</a>
<a class="diff-line-num" data-line-number="16" href="#L16" id="L16">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
16
</a>
<a class="diff-line-num" data-line-number="17" href="#L17" id="L17">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
17
</a>
<a class="diff-line-num" data-line-number="18" href="#L18" id="L18">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
18
</a>
<a class="diff-line-num" data-line-number="19" href="#L19" id="L19">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
19
</a>
<a class="diff-line-num" data-line-number="20" href="#L20" id="L20">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
20
</a>
<a class="diff-line-num" data-line-number="21" href="#L21" id="L21">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
21
</a>
<a class="diff-line-num" data-line-number="22" href="#L22" id="L22">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
22
</a>
<a class="diff-line-num" data-line-number="23" href="#L23" id="L23">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
23
</a>
<a class="diff-line-num" data-line-number="24" href="#L24" id="L24">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
24
</a>
<a class="diff-line-num" data-line-number="25" href="#L25" id="L25">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
25
</a>
<a class="diff-line-num" data-line-number="26" href="#L26" id="L26">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
26
</a>
<a class="diff-line-num" data-line-number="27" href="#L27" id="L27">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
27
</a>
<a class="diff-line-num" data-line-number="28" href="#L28" id="L28">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
28
</a>
<a class="diff-line-num" data-line-number="29" href="#L29" id="L29">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
29
</a>
<a class="diff-line-num" data-line-number="30" href="#L30" id="L30">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
30
</a>
<a class="diff-line-num" data-line-number="31" href="#L31" id="L31">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
31
</a>
<a class="diff-line-num" data-line-number="32" href="#L32" id="L32">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
32
</a>
<a class="diff-line-num" data-line-number="33" href="#L33" id="L33">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
33
</a>
<a class="diff-line-num" data-line-number="34" href="#L34" id="L34">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
34
</a>
<a class="diff-line-num" data-line-number="35" href="#L35" id="L35">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
35
</a>
<a class="diff-line-num" data-line-number="36" href="#L36" id="L36">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
36
</a>
<a class="diff-line-num" data-line-number="37" href="#L37" id="L37">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
37
</a>
<a class="diff-line-num" data-line-number="38" href="#L38" id="L38">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
38
</a>
<a class="diff-line-num" data-line-number="39" href="#L39" id="L39">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
39
</a>
<a class="diff-line-num" data-line-number="40" href="#L40" id="L40">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
40
</a>
<a class="diff-line-num" data-line-number="41" href="#L41" id="L41">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
41
</a>
<a class="diff-line-num" data-line-number="42" href="#L42" id="L42">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
42
</a>
<a class="diff-line-num" data-line-number="43" href="#L43" id="L43">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
43
</a>
<a class="diff-line-num" data-line-number="44" href="#L44" id="L44">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
44
</a>
<a class="diff-line-num" data-line-number="45" href="#L45" id="L45">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
45
</a>
<a class="diff-line-num" data-line-number="46" href="#L46" id="L46">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
46
</a>
<a class="diff-line-num" data-line-number="47" href="#L47" id="L47">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
47
</a>
<a class="diff-line-num" data-line-number="48" href="#L48" id="L48">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
48
</a>
<a class="diff-line-num" data-line-number="49" href="#L49" id="L49">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
49
</a>
<a class="diff-line-num" data-line-number="50" href="#L50" id="L50">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
50
</a>
<a class="diff-line-num" data-line-number="51" href="#L51" id="L51">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
51
</a>
<a class="diff-line-num" data-line-number="52" href="#L52" id="L52">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
52
</a>
<a class="diff-line-num" data-line-number="53" href="#L53" id="L53">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
53
</a>
<a class="diff-line-num" data-line-number="54" href="#L54" id="L54">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
54
</a>
<a class="diff-line-num" data-line-number="55" href="#L55" id="L55">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
55
</a>
<a class="diff-line-num" data-line-number="56" href="#L56" id="L56">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
56
</a>
<a class="diff-line-num" data-line-number="57" href="#L57" id="L57">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
57
</a>
<a class="diff-line-num" data-line-number="58" href="#L58" id="L58">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
58
</a>
<a class="diff-line-num" data-line-number="59" href="#L59" id="L59">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
59
</a>
<a class="diff-line-num" data-line-number="60" href="#L60" id="L60">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
60
</a>
<a class="diff-line-num" data-line-number="61" href="#L61" id="L61">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
61
</a>
<a class="diff-line-num" data-line-number="62" href="#L62" id="L62">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
62
</a>
<a class="diff-line-num" data-line-number="63" href="#L63" id="L63">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
63
</a>
<a class="diff-line-num" data-line-number="64" href="#L64" id="L64">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
64
</a>
<a class="diff-line-num" data-line-number="65" href="#L65" id="L65">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
65
</a>
<a class="diff-line-num" data-line-number="66" href="#L66" id="L66">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
66
</a>
<a class="diff-line-num" data-line-number="67" href="#L67" id="L67">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
67
</a>
<a class="diff-line-num" data-line-number="68" href="#L68" id="L68">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
68
</a>
<a class="diff-line-num" data-line-number="69" href="#L69" id="L69">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
69
</a>
<a class="diff-line-num" data-line-number="70" href="#L70" id="L70">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
70
</a>
<a class="diff-line-num" data-line-number="71" href="#L71" id="L71">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
71
</a>
<a class="diff-line-num" data-line-number="72" href="#L72" id="L72">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
72
</a>
<a class="diff-line-num" data-line-number="73" href="#L73" id="L73">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
73
</a>
<a class="diff-line-num" data-line-number="74" href="#L74" id="L74">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
74
</a>
<a class="diff-line-num" data-line-number="75" href="#L75" id="L75">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
75
</a>
<a class="diff-line-num" data-line-number="76" href="#L76" id="L76">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
76
</a>
<a class="diff-line-num" data-line-number="77" href="#L77" id="L77">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
77
</a>
<a class="diff-line-num" data-line-number="78" href="#L78" id="L78">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
78
</a>
<a class="diff-line-num" data-line-number="79" href="#L79" id="L79">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
79
</a>
<a class="diff-line-num" data-line-number="80" href="#L80" id="L80">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
80
</a>
<a class="diff-line-num" data-line-number="81" href="#L81" id="L81">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
81
</a>
<a class="diff-line-num" data-line-number="82" href="#L82" id="L82">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
82
</a>
<a class="diff-line-num" data-line-number="83" href="#L83" id="L83">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
83
</a>
<a class="diff-line-num" data-line-number="84" href="#L84" id="L84">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
84
</a>
<a class="diff-line-num" data-line-number="85" href="#L85" id="L85">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
85
</a>
<a class="diff-line-num" data-line-number="86" href="#L86" id="L86">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
86
</a>
<a class="diff-line-num" data-line-number="87" href="#L87" id="L87">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
87
</a>
<a class="diff-line-num" data-line-number="88" href="#L88" id="L88">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
88
</a>
<a class="diff-line-num" data-line-number="89" href="#L89" id="L89">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
89
</a>
<a class="diff-line-num" data-line-number="90" href="#L90" id="L90">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
90
</a>
<a class="diff-line-num" data-line-number="91" href="#L91" id="L91">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
91
</a>
<a class="diff-line-num" data-line-number="92" href="#L92" id="L92">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
92
</a>
<a class="diff-line-num" data-line-number="93" href="#L93" id="L93">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
93
</a>
<a class="diff-line-num" data-line-number="94" href="#L94" id="L94">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
94
</a>
<a class="diff-line-num" data-line-number="95" href="#L95" id="L95">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
95
</a>
<a class="diff-line-num" data-line-number="96" href="#L96" id="L96">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
96
</a>
<a class="diff-line-num" data-line-number="97" href="#L97" id="L97">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
97
</a>
<a class="diff-line-num" data-line-number="98" href="#L98" id="L98">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
98
</a>
<a class="diff-line-num" data-line-number="99" href="#L99" id="L99">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
99
</a>
<a class="diff-line-num" data-line-number="100" href="#L100" id="L100">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
100
</a>
<a class="diff-line-num" data-line-number="101" href="#L101" id="L101">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
101
</a>
<a class="diff-line-num" data-line-number="102" href="#L102" id="L102">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
102
</a>
<a class="diff-line-num" data-line-number="103" href="#L103" id="L103">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
103
</a>
<a class="diff-line-num" data-line-number="104" href="#L104" id="L104">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
104
</a>
<a class="diff-line-num" data-line-number="105" href="#L105" id="L105">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
105
</a>
<a class="diff-line-num" data-line-number="106" href="#L106" id="L106">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
106
</a>
<a class="diff-line-num" data-line-number="107" href="#L107" id="L107">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
107
</a>
<a class="diff-line-num" data-line-number="108" href="#L108" id="L108">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
108
</a>
<a class="diff-line-num" data-line-number="109" href="#L109" id="L109">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
109
</a>
<a class="diff-line-num" data-line-number="110" href="#L110" id="L110">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
110
</a>
<a class="diff-line-num" data-line-number="111" href="#L111" id="L111">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
111
</a>
<a class="diff-line-num" data-line-number="112" href="#L112" id="L112">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
112
</a>
<a class="diff-line-num" data-line-number="113" href="#L113" id="L113">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
113
</a>
<a class="diff-line-num" data-line-number="114" href="#L114" id="L114">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
114
</a>
<a class="diff-line-num" data-line-number="115" href="#L115" id="L115">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
115
</a>
<a class="diff-line-num" data-line-number="116" href="#L116" id="L116">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
116
</a>
<a class="diff-line-num" data-line-number="117" href="#L117" id="L117">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
117
</a>
<a class="diff-line-num" data-line-number="118" href="#L118" id="L118">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
118
</a>
<a class="diff-line-num" data-line-number="119" href="#L119" id="L119">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
119
</a>
<a class="diff-line-num" data-line-number="120" href="#L120" id="L120">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
120
</a>
<a class="diff-line-num" data-line-number="121" href="#L121" id="L121">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
121
</a>
<a class="diff-line-num" data-line-number="122" href="#L122" id="L122">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
122
</a>
<a class="diff-line-num" data-line-number="123" href="#L123" id="L123">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
123
</a>
<a class="diff-line-num" data-line-number="124" href="#L124" id="L124">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
124
</a>
<a class="diff-line-num" data-line-number="125" href="#L125" id="L125">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
125
</a>
<a class="diff-line-num" data-line-number="126" href="#L126" id="L126">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
126
</a>
<a class="diff-line-num" data-line-number="127" href="#L127" id="L127">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
127
</a>
<a class="diff-line-num" data-line-number="128" href="#L128" id="L128">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
128
</a>
<a class="diff-line-num" data-line-number="129" href="#L129" id="L129">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
129
</a>
<a class="diff-line-num" data-line-number="130" href="#L130" id="L130">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
130
</a>
<a class="diff-line-num" data-line-number="131" href="#L131" id="L131">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
131
</a>
<a class="diff-line-num" data-line-number="132" href="#L132" id="L132">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
132
</a>
<a class="diff-line-num" data-line-number="133" href="#L133" id="L133">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
133
</a>
<a class="diff-line-num" data-line-number="134" href="#L134" id="L134">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
134
</a>
<a class="diff-line-num" data-line-number="135" href="#L135" id="L135">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
135
</a>
<a class="diff-line-num" data-line-number="136" href="#L136" id="L136">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
136
</a>
<a class="diff-line-num" data-line-number="137" href="#L137" id="L137">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
137
</a>
<a class="diff-line-num" data-line-number="138" href="#L138" id="L138">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
138
</a>
<a class="diff-line-num" data-line-number="139" href="#L139" id="L139">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
139
</a>
<a class="diff-line-num" data-line-number="140" href="#L140" id="L140">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
140
</a>
<a class="diff-line-num" data-line-number="141" href="#L141" id="L141">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
141
</a>
<a class="diff-line-num" data-line-number="142" href="#L142" id="L142">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
142
</a>
<a class="diff-line-num" data-line-number="143" href="#L143" id="L143">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
143
</a>
<a class="diff-line-num" data-line-number="144" href="#L144" id="L144">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
144
</a>
<a class="diff-line-num" data-line-number="145" href="#L145" id="L145">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
145
</a>
<a class="diff-line-num" data-line-number="146" href="#L146" id="L146">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
146
</a>
<a class="diff-line-num" data-line-number="147" href="#L147" id="L147">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
147
</a>
<a class="diff-line-num" data-line-number="148" href="#L148" id="L148">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
148
</a>
<a class="diff-line-num" data-line-number="149" href="#L149" id="L149">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
149
</a>
<a class="diff-line-num" data-line-number="150" href="#L150" id="L150">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
150
</a>
<a class="diff-line-num" data-line-number="151" href="#L151" id="L151">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
151
</a>
<a class="diff-line-num" data-line-number="152" href="#L152" id="L152">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
152
</a>
<a class="diff-line-num" data-line-number="153" href="#L153" id="L153">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
153
</a>
<a class="diff-line-num" data-line-number="154" href="#L154" id="L154">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
154
</a>
<a class="diff-line-num" data-line-number="155" href="#L155" id="L155">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
155
</a>
<a class="diff-line-num" data-line-number="156" href="#L156" id="L156">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
156
</a>
<a class="diff-line-num" data-line-number="157" href="#L157" id="L157">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
157
</a>
<a class="diff-line-num" data-line-number="158" href="#L158" id="L158">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
158
</a>
<a class="diff-line-num" data-line-number="159" href="#L159" id="L159">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
159
</a>
<a class="diff-line-num" data-line-number="160" href="#L160" id="L160">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
160
</a>
<a class="diff-line-num" data-line-number="161" href="#L161" id="L161">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
161
</a>
<a class="diff-line-num" data-line-number="162" href="#L162" id="L162">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
162
</a>
<a class="diff-line-num" data-line-number="163" href="#L163" id="L163">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
163
</a>
<a class="diff-line-num" data-line-number="164" href="#L164" id="L164">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
164
</a>
<a class="diff-line-num" data-line-number="165" href="#L165" id="L165">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
165
</a>
<a class="diff-line-num" data-line-number="166" href="#L166" id="L166">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
166
</a>
<a class="diff-line-num" data-line-number="167" href="#L167" id="L167">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
167
</a>
<a class="diff-line-num" data-line-number="168" href="#L168" id="L168">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
168
</a>
<a class="diff-line-num" data-line-number="169" href="#L169" id="L169">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
169
</a>
<a class="diff-line-num" data-line-number="170" href="#L170" id="L170">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
170
</a>
<a class="diff-line-num" data-line-number="171" href="#L171" id="L171">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
171
</a>
<a class="diff-line-num" data-line-number="172" href="#L172" id="L172">
<i aria-hidden="true" data-hidden="true" class="fa fa-link"></i>
172
</a>
</div>
<div class="blob-content" data-blob-id="ee69145485df1f9d6af54041889079c6db435b09">
<pre class="code highlight"><code><span id="LC1" class="line" lang="go"><span class="k">package</span><span class="x"> </span><span class="n">shell</span></span>
<span id="LC2" class="line" lang="go"></span>
<span id="LC3" class="line" lang="go"><span class="k">import</span><span class="x"> </span><span class="p">(</span></span>
<span id="LC4" class="line" lang="go"><span class="x">	</span><span class="s">"bytes"</span></span>
<span id="LC5" class="line" lang="go"><span class="x">	</span><span class="s">"errors"</span></span>
<span id="LC6" class="line" lang="go"><span class="x">	</span><span class="s">"fmt"</span></span>
<span id="LC7" class="line" lang="go"><span class="x">	</span><span class="s">"io/ioutil"</span></span>
<span id="LC8" class="line" lang="go"><span class="x">	</span><span class="s">"os"</span></span>
<span id="LC9" class="line" lang="go"><span class="x">	</span><span class="s">"os/exec"</span></span>
<span id="LC10" class="line" lang="go"><span class="x">	</span><span class="s">"path/filepath"</span></span>
<span id="LC11" class="line" lang="go"><span class="x">	</span><span class="s">"runtime"</span></span>
<span id="LC12" class="line" lang="go"><span class="x">	</span><span class="s">"time"</span></span>
<span id="LC13" class="line" lang="go"></span>
<span id="LC14" class="line" lang="go"><span class="x">	</span><span class="s">"github.com/kardianos/osext"</span></span>
<span id="LC15" class="line" lang="go"><span class="x">	</span><span class="s">"github.com/sirupsen/logrus"</span></span>
<span id="LC16" class="line" lang="go"></span>
<span id="LC17" class="line" lang="go"><span class="x">	</span><span class="s">"gitlab.com/gitlab-org/gitlab-runner/common"</span></span>
<span id="LC18" class="line" lang="go"><span class="x">	</span><span class="s">"gitlab.com/gitlab-org/gitlab-runner/executors"</span></span>
<span id="LC19" class="line" lang="go"><span class="x">	</span><span class="s">"gitlab.com/gitlab-org/gitlab-runner/helpers"</span></span>
<span id="LC20" class="line" lang="go"><span class="p">)</span></span>
<span id="LC21" class="line" lang="go"></span>
<span id="LC22" class="line" lang="go"><span class="k">type</span><span class="x"> </span><span class="n">executor</span><span class="x"> </span><span class="k">struct</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC23" class="line" lang="go"><span class="x">	</span><span class="n">executors</span><span class="o">.</span><span class="n">AbstractExecutor</span></span>
<span id="LC24" class="line" lang="go"><span class="p">}</span></span>
<span id="LC25" class="line" lang="go"></span>
<span id="LC26" class="line" lang="go"><span class="k">func</span><span class="x"> </span><span class="p">(</span><span class="n">s</span><span class="x"> </span><span class="o">*</span><span class="n">executor</span><span class="p">)</span><span class="x"> </span><span class="n">Prepare</span><span class="p">(</span><span class="n">options</span><span class="x"> </span><span class="n">common</span><span class="o">.</span><span class="n">ExecutorPrepareOptions</span><span class="p">)</span><span class="x"> </span><span class="kt">error</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC27" class="line" lang="go"><span class="x">	</span><span class="k">if</span><span class="x"> </span><span class="n">options</span><span class="o">.</span><span class="n">User</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="s">""</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC28" class="line" lang="go"><span class="x">		</span><span class="n">s</span><span class="o">.</span><span class="n">Shell</span><span class="p">()</span><span class="o">.</span><span class="n">User</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">options</span><span class="o">.</span><span class="n">User</span></span>
<span id="LC29" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC30" class="line" lang="go"></span>
<span id="LC31" class="line" lang="go"><span class="x">	</span><span class="c">// expand environment variables to have current directory</span></span>
<span id="LC32" class="line" lang="go"><span class="x">	</span><span class="n">wd</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">os</span><span class="o">.</span><span class="n">Getwd</span><span class="p">()</span></span>
<span id="LC33" class="line" lang="go"><span class="x">	</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC34" class="line" lang="go"><span class="x">		</span><span class="k">return</span><span class="x"> </span><span class="n">fmt</span><span class="o">.</span><span class="n">Errorf</span><span class="p">(</span><span class="s">"Getwd: %v"</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="p">)</span></span>
<span id="LC35" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC36" class="line" lang="go"></span>
<span id="LC37" class="line" lang="go"><span class="x">	</span><span class="n">mapping</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="k">func</span><span class="p">(</span><span class="n">key</span><span class="x"> </span><span class="kt">string</span><span class="p">)</span><span class="x"> </span><span class="kt">string</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC38" class="line" lang="go"><span class="x">		</span><span class="k">switch</span><span class="x"> </span><span class="n">key</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC39" class="line" lang="go"><span class="x">		</span><span class="k">case</span><span class="x"> </span><span class="s">"PWD"</span><span class="o">:</span></span>
<span id="LC40" class="line" lang="go"><span class="x">			</span><span class="k">return</span><span class="x"> </span><span class="n">wd</span></span>
<span id="LC41" class="line" lang="go"><span class="x">		</span><span class="k">default</span><span class="o">:</span></span>
<span id="LC42" class="line" lang="go"><span class="x">			</span><span class="k">return</span><span class="x"> </span><span class="s">""</span></span>
<span id="LC43" class="line" lang="go"><span class="x">		</span><span class="p">}</span></span>
<span id="LC44" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC45" class="line" lang="go"></span>
<span id="LC46" class="line" lang="go"><span class="x">	</span><span class="n">s</span><span class="o">.</span><span class="n">DefaultBuildsDir</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">os</span><span class="o">.</span><span class="n">Expand</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">DefaultBuildsDir</span><span class="p">,</span><span class="x"> </span><span class="n">mapping</span><span class="p">)</span></span>
<span id="LC47" class="line" lang="go"><span class="x">	</span><span class="n">s</span><span class="o">.</span><span class="n">DefaultCacheDir</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">os</span><span class="o">.</span><span class="n">Expand</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">DefaultCacheDir</span><span class="p">,</span><span class="x"> </span><span class="n">mapping</span><span class="p">)</span></span>
<span id="LC48" class="line" lang="go"></span>
<span id="LC49" class="line" lang="go"><span class="x">	</span><span class="c">// Pass control to executor</span></span>
<span id="LC50" class="line" lang="go"><span class="x">	</span><span class="n">err</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">s</span><span class="o">.</span><span class="n">AbstractExecutor</span><span class="o">.</span><span class="n">Prepare</span><span class="p">(</span><span class="n">options</span><span class="p">)</span></span>
<span id="LC51" class="line" lang="go"><span class="x">	</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC52" class="line" lang="go"><span class="x">		</span><span class="k">return</span><span class="x"> </span><span class="n">err</span></span>
<span id="LC53" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC54" class="line" lang="go"></span>
<span id="LC55" class="line" lang="go"><span class="x">	</span><span class="n">s</span><span class="o">.</span><span class="n">Println</span><span class="p">(</span><span class="s">"Using Shell executor..."</span><span class="p">)</span></span>
<span id="LC56" class="line" lang="go"><span class="x">	</span><span class="k">return</span><span class="x"> </span><span class="no">nil</span></span>
<span id="LC57" class="line" lang="go"><span class="p">}</span></span>
<span id="LC58" class="line" lang="go"></span>
<span id="LC59" class="line" lang="go"><span class="k">func</span><span class="x"> </span><span class="p">(</span><span class="n">s</span><span class="x"> </span><span class="o">*</span><span class="n">executor</span><span class="p">)</span><span class="x"> </span><span class="n">killAndWait</span><span class="p">(</span><span class="n">cmd</span><span class="x"> </span><span class="o">*</span><span class="n">exec</span><span class="o">.</span><span class="n">Cmd</span><span class="p">,</span><span class="x"> </span><span class="n">waitCh</span><span class="x"> </span><span class="k">chan</span><span class="x"> </span><span class="kt">error</span><span class="p">)</span><span class="x"> </span><span class="kt">error</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC60" class="line" lang="go"><span class="x">	</span><span class="k">for</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC61" class="line" lang="go"><span class="x">		</span><span class="n">s</span><span class="o">.</span><span class="n">Debugln</span><span class="p">(</span><span class="s">"Aborting command..."</span><span class="p">)</span></span>
<span id="LC62" class="line" lang="go"><span class="x">		</span><span class="n">helpers</span><span class="o">.</span><span class="n">KillProcessGroup</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span></span>
<span id="LC63" class="line" lang="go"><span class="x">		</span><span class="k">select</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC64" class="line" lang="go"><span class="x">		</span><span class="k">case</span><span class="x"> </span><span class="o">&lt;-</span><span class="n">time</span><span class="o">.</span><span class="n">After</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">Second</span><span class="p">)</span><span class="o">:</span></span>
<span id="LC65" class="line" lang="go"><span class="x">		</span><span class="k">case</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="o">&lt;-</span><span class="n">waitCh</span><span class="o">:</span></span>
<span id="LC66" class="line" lang="go"><span class="x">			</span><span class="k">return</span><span class="x"> </span><span class="n">err</span></span>
<span id="LC67" class="line" lang="go"><span class="x">		</span><span class="p">}</span></span>
<span id="LC68" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC69" class="line" lang="go"><span class="p">}</span></span>
<span id="LC70" class="line" lang="go"></span>
<span id="LC71" class="line" lang="go"><span class="k">func</span><span class="x"> </span><span class="p">(</span><span class="n">s</span><span class="x"> </span><span class="o">*</span><span class="n">executor</span><span class="p">)</span><span class="x"> </span><span class="n">Run</span><span class="p">(</span><span class="n">cmd</span><span class="x"> </span><span class="n">common</span><span class="o">.</span><span class="n">ExecutorCommand</span><span class="p">)</span><span class="x"> </span><span class="kt">error</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC72" class="line" lang="go"><span class="x">	</span><span class="c">// Create execution command</span></span>
<span id="LC73" class="line" lang="go"><span class="x">	</span><span class="n">c</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">exec</span><span class="o">.</span><span class="n">Command</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">BuildShell</span><span class="o">.</span><span class="n">Command</span><span class="p">,</span><span class="x"> </span><span class="n">s</span><span class="o">.</span><span class="n">BuildShell</span><span class="o">.</span><span class="n">Arguments</span><span class="o">...</span><span class="p">)</span></span>
<span id="LC74" class="line" lang="go"><span class="x">	</span><span class="k">if</span><span class="x"> </span><span class="n">c</span><span class="x"> </span><span class="o">==</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC75" class="line" lang="go"><span class="x">		</span><span class="k">return</span><span class="x"> </span><span class="n">errors</span><span class="o">.</span><span class="n">New</span><span class="p">(</span><span class="s">"Failed to generate execution command"</span><span class="p">)</span></span>
<span id="LC76" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC77" class="line" lang="go"></span>
<span id="LC78" class="line" lang="go"><span class="x">	</span><span class="n">helpers</span><span class="o">.</span><span class="n">SetProcessGroup</span><span class="p">(</span><span class="n">c</span><span class="p">)</span></span>
<span id="LC79" class="line" lang="go"><span class="x">	</span><span class="k">defer</span><span class="x"> </span><span class="n">helpers</span><span class="o">.</span><span class="n">KillProcessGroup</span><span class="p">(</span><span class="n">c</span><span class="p">)</span></span>
<span id="LC80" class="line" lang="go"></span>
<span id="LC81" class="line" lang="go"><span class="x">	</span><span class="c">// Fill process environment variables</span></span>
<span id="LC82" class="line" lang="go"><span class="x">	</span><span class="n">c</span><span class="o">.</span><span class="n">Env</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="nb">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">Environ</span><span class="p">(),</span><span class="x"> </span><span class="n">s</span><span class="o">.</span><span class="n">BuildShell</span><span class="o">.</span><span class="n">Environment</span><span class="o">...</span><span class="p">)</span></span>
<span id="LC83" class="line" lang="go"><span class="x">	</span><span class="n">c</span><span class="o">.</span><span class="n">Stdout</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">s</span><span class="o">.</span><span class="n">Trace</span></span>
<span id="LC84" class="line" lang="go"><span class="x">	</span><span class="n">c</span><span class="o">.</span><span class="n">Stderr</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">s</span><span class="o">.</span><span class="n">Trace</span></span>
<span id="LC85" class="line" lang="go"></span>
<span id="LC86" class="line" lang="go"><span class="x">	</span><span class="k">if</span><span class="x"> </span><span class="n">s</span><span class="o">.</span><span class="n">BuildShell</span><span class="o">.</span><span class="n">PassFile</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC87" class="line" lang="go"><span class="x">		</span><span class="n">scriptDir</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">ioutil</span><span class="o">.</span><span class="n">TempDir</span><span class="p">(</span><span class="s">""</span><span class="p">,</span><span class="x"> </span><span class="s">"build_script"</span><span class="p">)</span></span>
<span id="LC88" class="line" lang="go"><span class="x">		</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC89" class="line" lang="go"><span class="x">			</span><span class="k">return</span><span class="x"> </span><span class="n">err</span></span>
<span id="LC90" class="line" lang="go"><span class="x">		</span><span class="p">}</span></span>
<span id="LC91" class="line" lang="go"><span class="x">		</span><span class="k">defer</span><span class="x"> </span><span class="n">os</span><span class="o">.</span><span class="n">RemoveAll</span><span class="p">(</span><span class="n">scriptDir</span><span class="p">)</span></span>
<span id="LC92" class="line" lang="go"></span>
<span id="LC93" class="line" lang="go"><span class="x">		</span><span class="n">scriptFile</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">filepath</span><span class="o">.</span><span class="n">Join</span><span class="p">(</span><span class="n">scriptDir</span><span class="p">,</span><span class="x"> </span><span class="s">"script."</span><span class="o">+</span><span class="n">s</span><span class="o">.</span><span class="n">BuildShell</span><span class="o">.</span><span class="n">Extension</span><span class="p">)</span></span>
<span id="LC94" class="line" lang="go"><span class="x">		</span><span class="n">err</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">ioutil</span><span class="o">.</span><span class="n">WriteFile</span><span class="p">(</span><span class="n">scriptFile</span><span class="p">,</span><span class="x"> </span><span class="p">[]</span><span class="kt">byte</span><span class="p">(</span><span class="n">cmd</span><span class="o">.</span><span class="n">Script</span><span class="p">),</span><span class="x"> </span><span class="m">0700</span><span class="p">)</span></span>
<span id="LC95" class="line" lang="go"><span class="x">		</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC96" class="line" lang="go"><span class="x">			</span><span class="k">return</span><span class="x"> </span><span class="n">err</span></span>
<span id="LC97" class="line" lang="go"><span class="x">		</span><span class="p">}</span></span>
<span id="LC98" class="line" lang="go"></span>
<span id="LC99" class="line" lang="go"><span class="x">		</span><span class="n">c</span><span class="o">.</span><span class="n">Args</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="nb">append</span><span class="p">(</span><span class="n">c</span><span class="o">.</span><span class="n">Args</span><span class="p">,</span><span class="x"> </span><span class="n">scriptFile</span><span class="p">)</span></span>
<span id="LC100" class="line" lang="go"><span class="x">	</span><span class="p">}</span><span class="x"> </span><span class="k">else</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC101" class="line" lang="go"><span class="x">		</span><span class="n">c</span><span class="o">.</span><span class="n">Stdin</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="n">bytes</span><span class="o">.</span><span class="n">NewBufferString</span><span class="p">(</span><span class="n">cmd</span><span class="o">.</span><span class="n">Script</span><span class="p">)</span></span>
<span id="LC102" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC103" class="line" lang="go"></span>
<span id="LC104" class="line" lang="go"><span class="x">	</span><span class="c">// Start a process</span></span>
<span id="LC105" class="line" lang="go"><span class="x">	</span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">c</span><span class="o">.</span><span class="n">Start</span><span class="p">()</span></span>
<span id="LC106" class="line" lang="go"><span class="x">	</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC107" class="line" lang="go"><span class="x">		</span><span class="k">return</span><span class="x"> </span><span class="n">fmt</span><span class="o">.</span><span class="n">Errorf</span><span class="p">(</span><span class="s">"Failed to start process: %s"</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="p">)</span></span>
<span id="LC108" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC109" class="line" lang="go"></span>
<span id="LC110" class="line" lang="go"><span class="x">	</span><span class="c">// Wait for process to finish</span></span>
<span id="LC111" class="line" lang="go"><span class="x">	</span><span class="n">waitCh</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="nb">make</span><span class="p">(</span><span class="k">chan</span><span class="x"> </span><span class="kt">error</span><span class="p">)</span></span>
<span id="LC112" class="line" lang="go"><span class="x">	</span><span class="k">go</span><span class="x"> </span><span class="k">func</span><span class="p">()</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC113" class="line" lang="go"><span class="x">		</span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">c</span><span class="o">.</span><span class="n">Wait</span><span class="p">()</span></span>
<span id="LC114" class="line" lang="go"><span class="x">		</span><span class="k">if</span><span class="x"> </span><span class="n">_</span><span class="p">,</span><span class="x"> </span><span class="n">ok</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">err</span><span class="o">.</span><span class="p">(</span><span class="o">*</span><span class="n">exec</span><span class="o">.</span><span class="n">ExitError</span><span class="p">);</span><span class="x"> </span><span class="n">ok</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC115" class="line" lang="go"><span class="x">			</span><span class="n">err</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="o">&amp;</span><span class="n">common</span><span class="o">.</span><span class="n">BuildError</span><span class="p">{</span><span class="n">Inner</span><span class="o">:</span><span class="x"> </span><span class="n">err</span><span class="p">}</span></span>
<span id="LC116" class="line" lang="go"><span class="x">		</span><span class="p">}</span></span>
<span id="LC117" class="line" lang="go"><span class="x">		</span><span class="n">waitCh</span><span class="x"> </span><span class="o">&lt;-</span><span class="x"> </span><span class="n">err</span></span>
<span id="LC118" class="line" lang="go"><span class="x">	</span><span class="p">}()</span></span>
<span id="LC119" class="line" lang="go"></span>
<span id="LC120" class="line" lang="go"><span class="x">	</span><span class="c">// Support process abort</span></span>
<span id="LC121" class="line" lang="go"><span class="x">	</span><span class="k">select</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC122" class="line" lang="go"><span class="x">	</span><span class="k">case</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="o">&lt;-</span><span class="n">waitCh</span><span class="o">:</span></span>
<span id="LC123" class="line" lang="go"><span class="x">		</span><span class="k">return</span><span class="x"> </span><span class="n">err</span></span>
<span id="LC124" class="line" lang="go"></span>
<span id="LC125" class="line" lang="go"><span class="x">	</span><span class="k">case</span><span class="x"> </span><span class="o">&lt;-</span><span class="n">cmd</span><span class="o">.</span><span class="n">Context</span><span class="o">.</span><span class="n">Done</span><span class="p">()</span><span class="o">:</span></span>
<span id="LC126" class="line" lang="go"><span class="x">		</span><span class="k">return</span><span class="x"> </span><span class="n">s</span><span class="o">.</span><span class="n">killAndWait</span><span class="p">(</span><span class="n">c</span><span class="p">,</span><span class="x"> </span><span class="n">waitCh</span><span class="p">)</span></span>
<span id="LC127" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC128" class="line" lang="go"><span class="p">}</span></span>
<span id="LC129" class="line" lang="go"></span>
<span id="LC130" class="line" lang="go"><span class="k">func</span><span class="x"> </span><span class="n">init</span><span class="p">()</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC131" class="line" lang="go"><span class="x">	</span><span class="c">// Look for self</span></span>
<span id="LC132" class="line" lang="go"><span class="x">	</span><span class="n">runnerCommand</span><span class="p">,</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">osext</span><span class="o">.</span><span class="n">Executable</span><span class="p">()</span></span>
<span id="LC133" class="line" lang="go"><span class="x">	</span><span class="k">if</span><span class="x"> </span><span class="n">err</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="no">nil</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC134" class="line" lang="go"><span class="x">		</span><span class="n">logrus</span><span class="o">.</span><span class="n">Warningln</span><span class="p">(</span><span class="n">err</span><span class="p">)</span></span>
<span id="LC135" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC136" class="line" lang="go"></span>
<span id="LC137" class="line" lang="go"><span class="x">	</span><span class="n">options</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="n">executors</span><span class="o">.</span><span class="n">ExecutorOptions</span><span class="p">{</span></span>
<span id="LC138" class="line" lang="go"><span class="x">		</span><span class="n">DefaultBuildsDir</span><span class="o">:</span><span class="x"> </span><span class="s">"$PWD/builds"</span><span class="p">,</span></span>
<span id="LC139" class="line" lang="go"><span class="x">		</span><span class="n">DefaultCacheDir</span><span class="o">:</span><span class="x">  </span><span class="s">"$PWD/cache"</span><span class="p">,</span></span>
<span id="LC140" class="line" lang="go"><span class="x">		</span><span class="n">SharedBuildsDir</span><span class="o">:</span><span class="x">  </span><span class="no">true</span><span class="p">,</span></span>
<span id="LC141" class="line" lang="go"><span class="x">		</span><span class="n">Shell</span><span class="o">:</span><span class="x"> </span><span class="n">common</span><span class="o">.</span><span class="n">ShellScriptInfo</span><span class="p">{</span></span>
<span id="LC142" class="line" lang="go"><span class="x">			</span><span class="n">Shell</span><span class="o">:</span><span class="x">         </span><span class="n">common</span><span class="o">.</span><span class="n">GetDefaultShell</span><span class="p">(),</span></span>
<span id="LC143" class="line" lang="go"><span class="x">			</span><span class="n">Type</span><span class="o">:</span><span class="x">          </span><span class="n">common</span><span class="o">.</span><span class="n">LoginShell</span><span class="p">,</span></span>
<span id="LC144" class="line" lang="go"><span class="x">			</span><span class="n">RunnerCommand</span><span class="o">:</span><span class="x"> </span><span class="n">runnerCommand</span><span class="p">,</span></span>
<span id="LC145" class="line" lang="go"><span class="x">		</span><span class="p">},</span></span>
<span id="LC146" class="line" lang="go"><span class="x">		</span><span class="n">ShowHostname</span><span class="o">:</span><span class="x"> </span><span class="no">false</span><span class="p">,</span></span>
<span id="LC147" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC148" class="line" lang="go"></span>
<span id="LC149" class="line" lang="go"><span class="x">	</span><span class="n">creator</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="k">func</span><span class="p">()</span><span class="x"> </span><span class="n">common</span><span class="o">.</span><span class="n">Executor</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC150" class="line" lang="go"><span class="x">		</span><span class="k">return</span><span class="x"> </span><span class="o">&amp;</span><span class="n">executor</span><span class="p">{</span></span>
<span id="LC151" class="line" lang="go"><span class="x">			</span><span class="n">AbstractExecutor</span><span class="o">:</span><span class="x"> </span><span class="n">executors</span><span class="o">.</span><span class="n">AbstractExecutor</span><span class="p">{</span></span>
<span id="LC152" class="line" lang="go"><span class="x">				</span><span class="n">ExecutorOptions</span><span class="o">:</span><span class="x"> </span><span class="n">options</span><span class="p">,</span></span>
<span id="LC153" class="line" lang="go"><span class="x">			</span><span class="p">},</span></span>
<span id="LC154" class="line" lang="go"><span class="x">		</span><span class="p">}</span></span>
<span id="LC155" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC156" class="line" lang="go"></span>
<span id="LC157" class="line" lang="go"><span class="x">	</span><span class="n">featuresUpdater</span><span class="x"> </span><span class="o">:=</span><span class="x"> </span><span class="k">func</span><span class="p">(</span><span class="n">features</span><span class="x"> </span><span class="o">*</span><span class="n">common</span><span class="o">.</span><span class="n">FeaturesInfo</span><span class="p">)</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC158" class="line" lang="go"><span class="x">		</span><span class="n">features</span><span class="o">.</span><span class="n">Variables</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="no">true</span></span>
<span id="LC159" class="line" lang="go"><span class="x">		</span><span class="n">features</span><span class="o">.</span><span class="n">Shared</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="no">true</span></span>
<span id="LC160" class="line" lang="go"></span>
<span id="LC161" class="line" lang="go"><span class="x">		</span><span class="k">if</span><span class="x"> </span><span class="n">runtime</span><span class="o">.</span><span class="n">GOOS</span><span class="x"> </span><span class="o">!=</span><span class="x"> </span><span class="s">"windows"</span><span class="x"> </span><span class="p">{</span></span>
<span id="LC162" class="line" lang="go"><span class="x">			</span><span class="n">features</span><span class="o">.</span><span class="n">Session</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="no">true</span></span>
<span id="LC163" class="line" lang="go"><span class="x">			</span><span class="n">features</span><span class="o">.</span><span class="n">Terminal</span><span class="x"> </span><span class="o">=</span><span class="x"> </span><span class="no">true</span></span>
<span id="LC164" class="line" lang="go"><span class="x">		</span><span class="p">}</span></span>
<span id="LC165" class="line" lang="go"><span class="x">	</span><span class="p">}</span></span>
<span id="LC166" class="line" lang="go"></span>
<span id="LC167" class="line" lang="go"><span class="x">	</span><span class="n">common</span><span class="o">.</span><span class="n">RegisterExecutor</span><span class="p">(</span><span class="s">"shell"</span><span class="p">,</span><span class="x"> </span><span class="n">executors</span><span class="o">.</span><span class="n">DefaultExecutorProvider</span><span class="p">{</span></span>
<span id="LC168" class="line" lang="go"><span class="x">		</span><span class="n">Creator</span><span class="o">:</span><span class="x">          </span><span class="n">creator</span><span class="p">,</span></span>
<span id="LC169" class="line" lang="go"><span class="x">		</span><span class="n">FeaturesUpdater</span><span class="o">:</span><span class="x">  </span><span class="n">featuresUpdater</span><span class="p">,</span></span>
<span id="LC170" class="line" lang="go"><span class="x">		</span><span class="n">DefaultShellName</span><span class="o">:</span><span class="x"> </span><span class="n">options</span><span class="o">.</span><span class="n">Shell</span><span class="o">.</span><span class="n">Shell</span><span class="p">,</span></span>
<span id="LC171" class="line" lang="go"><span class="x">	</span><span class="p">})</span></span>
<span id="LC172" class="line" lang="go"><span class="p">}</span></span></code></pre>
</div>
</div>


</div>
</div>


</article>
</div>
